#include "graphsupport/graph/operation/IGraphOperation.h"

IOperationSettings::IOperationSettings( int vertexCount )
	: vertexCount( vertexCount )
	, firstBipart( -1 )
	, secondBipart( -1 )

	, neighborsBeg( 1 )
	, neighborsRange( 1 )
	, cheapBeg( 1 )
	, cheapRange( 0 )
	, expensiveBeg( 1 )
	, expensiveRange( 0 )
	, facilityPriceBeg( 1 )
	, facilityPriceRange( 0 )

	, triangleIneqEnabled( false )

	, sampler( boost::mt19937( ( unsigned ) 12345 ), boost::uniform_int<>( 0, 1 << 30 ) )
{
}

IOperationSettings::IOperationSettings( int firstBipart, int secondBipart )
	: vertexCount( firstBipart + secondBipart )
	, firstBipart( firstBipart )
	, secondBipart( secondBipart )

	, neighborsBeg( 1 )
	, neighborsRange( 1 )
	, cheapBeg( 1 )
	, cheapRange( 0 )
	, expensiveBeg( 1 )
	, expensiveRange( 0 )
	, facilityPriceBeg( 1 )
	, facilityPriceRange( 0 )

	, triangleIneqEnabled( false )

	, sampler( boost::mt19937( ( unsigned ) 12345 ), boost::uniform_int<>( 0, 1 << 30 ) )
{
}

double IOperationSettings::randomDouble()
{
	int mask = ( 1 << 29 ) - 1;
	double result = ( sampler() & mask );
	result /= mask;
	return result;
}

int IOperationSettings::randomInt( int max )
{
	return sampler() % max;
}

void IOperationSettings::setRandomSeed( int value )
{
	sampler =
		boost::variate_generator< boost::mt19937, boost::uniform_int<> >(
			boost::mt19937( ( unsigned ) value ), boost::uniform_int<>( 0, 1 << 30 )
		);
}

IOperationSettings::~IOperationSettings()
{
}

IOperationSettings IOperationSettings::EMPTY_SETTINGS;

IGraphOperation::~IGraphOperation()
{
}
